<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    //冒泡排序是比较相邻的两个
    //选择排序是每个都和第一个进行比较
    let arrr = [10, 12, 45, 65, 562, 45, 458, 56]
    function selectSort(arr) {
      var teme = 0;
      for (var i = 0; i < arr.length; i++) {
        for (var j = i + 1; j < arr.length; j++) {
          if (arr[j] < arr[i]) {
            console.log(arr[j])
            teme = arr[j];
            arr[j] = arr[i];
            arr[i] = teme;
          }
        }
      }
      return arr

    }
    console.log(selectSort(arrr))
  </script>
</body>

</html>